package cn.edu.leetcode.单链表;

import java.util.ArrayList;

public class 环形链表 {

    public static boolean hasCycle(ListNode head) {
        ArrayList<ListNode> listNodes = new ArrayList<>();
        while (head != null){
            if (listNodes.contains(head)){
                return true;
            }
            listNodes.add(head);
            head = head.next;
        }
        return false;
    }

    public static void main(String[] args) {

    }

}


